Skip to content

Fix Blazor Identity scaffolding to target client project for WASM/Auto Global apps#3765

Open
haileymck wants to merge 1 commit into
mainfrom
copilot/fix-blazor-identity-scaffolding-bug
Open

Fix Blazor Identity scaffolding to target client project for WASM/Auto Global apps#3765
haileymck wants to merge 1 commit into
mainfrom
copilot/fix-blazor-identity-scaffolding-bug

Conversation

@haileymck

@haileymck haileymck commented May 19, 2026

Copy link
Copy Markdown
Member

In Blazor WASM/Auto Global interactivity projects, all interactive pages and layout components live in the .Client project, not the server project. The Identity scaffolder was always generating Account pages into the server project, so they were never reachable and no register/login UI appeared.

Fix: detect WASM/Auto Global projects by checking for the absence of Components/Layout/MainLayout.razor in the server project directory (same heuristic as PR #3764). When detected, redirect the scaffolded Account files to the .Client sibling project and update all namespaces accordingly.

Changes:

  • BlazorIdentityModel: add RootNamespace property for path resolution
  • BlazorIdentityGenerator (VS path): detect WASM/Auto Global via project references, set BaseOutputPath/BlazorIdentityNamespace/BlazorLayoutNamespace/ RootNamespace to the client project; use RootNamespace in ExecuteTemplates
  • IdentityModel (CLI): add IdentityProjectName for client project path resolution
  • ValidateIdentityStep (CLI): detect WASM/Auto Global via sibling .Client folder, set BaseOutputPath/IdentityNamespace/IdentityLayoutNamespace/IdentityProjectName
  • BlazorIdentityHelper (CLI): use IdentityProjectName in StringUtil.ToPath call
  • BlazorIdentityScaffolderBuilderExtensions (CLI): use IdentityModel.BaseOutputPath for static file placement instead of always using the server project directory

Does not repro on Blazor Server Global or per-page/component projects because MainLayout.razor exists in the server project for those configurations.

fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2993241

…o Global apps

In Blazor WASM/Auto Global interactivity projects, all interactive pages and
layout components live in the .Client project, not the server project. The
Identity scaffolder was always generating Account pages into the server project,
so they were never reachable and no register/login UI appeared.

Fix: detect WASM/Auto Global projects by checking for the absence of
Components/Layout/MainLayout.razor in the server project directory (same
heuristic as PR #3764). When detected, redirect the scaffolded Account files
to the .Client sibling project and update all namespaces accordingly.

Changes:
- BlazorIdentityModel: add RootNamespace property for path resolution
- BlazorIdentityGenerator (VS path): detect WASM/Auto Global via project
  references, set BaseOutputPath/BlazorIdentityNamespace/BlazorLayoutNamespace/
  RootNamespace to the client project; use RootNamespace in ExecuteTemplates
- IdentityModel (CLI): add IdentityProjectName for client project path resolution
- ValidateIdentityStep (CLI): detect WASM/Auto Global via sibling .Client folder,
  set BaseOutputPath/IdentityNamespace/IdentityLayoutNamespace/IdentityProjectName
- BlazorIdentityHelper (CLI): use IdentityProjectName in StringUtil.ToPath call
- BlazorIdentityScaffolderBuilderExtensions (CLI): use IdentityModel.BaseOutputPath
  for static file placement instead of always using the server project directory

Does not repro on Blazor Server Global or per-page/component projects because
MainLayout.razor exists in the server project for those configurations.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant